
***************************************************************************************************************
*										REPLICATION CODE FOR:
*							Julian Hoerner, Alex Jaax, Toni Rodon
*     The long-term impact of the location of concentration camps on radical right voting in Germany
*										Submitted to R&P
*										Run with Stata/SE 15.1
***************************************************************************************************************

************************
* Directory structure
************************

clear
clear matrix

global path `""/Users/rodoncas/Dropbox/Holocaust_Legacy_Paper/Analysis/Replication_R&P""'

cd $path

*global output "01_output\"

log using "output", text replace



********************************************************************************
*
*		PREPARE DATASET FOR ANALYSIS
*
********************************************************************************


*open distances data
use "Files/just_AGS_distance_camps.dta", clear


*We first need to drop a few repeated observations
sort ags
quietly by ags:  gen dup = cond(_N==1,0,_n)
*browse if dup==1
drop if dup==1
drop dup


*Merge the distances file with additional files
rename ags ags_num
gen str ags = string(ags_num,"%08.0f") /*needs to have a leading zero*/

*Merge it with historical controls
merge 1:1 ags using "Files/controls_historical_at_modern_spatial_level_withid.dta"
drop _merge

*merge with election results 
merge 1:1 ags using "Files/Second_and_First_2013_12.12.2017.dta"

*Create alternative radical right voting (without AfD)
egen p_radical_right_total = rowtotal(SECOND_NPD SECOND_DIERECHTE SECOND_REP SECOND_proDeutschland)
gen p_radical_right = (p_radical_right_total*100)/Second_total_cast

*encode Land
encode Land, gen(land_num) 

*generate log of distance
gen log_dist = log(distance_nearest_camp)

*gen % voting for spd, cdu and other parties
gen p_cdu = (SECOND_CDU*100)/Second_total_cast
gen p_spd = (SECOND_SPD*100)/Second_total_cast
gen p_fdp = (SECOND_FDP*100)/Second_total_cast
gen p_dielinke = (SECOND_DIELINKE*100)/Second_total_cast
gen p_grune = (SECOND_GRÜNE*100)/Second_total_cast

drop _merge


*Include demographic controls data
merge 1:1  ags using "Files/demographic_controls.dta"

*log transform population
destring density, gen(pop_density)
gen log_pop_density = log(1 + pop_density)

*Include income tax data
drop _merge
merge 1:1  ags using "Files/income_tax_2013.dta"

*Include unemployment data
drop _merge
merge 1:1  ags using "Files/unemployment_2013.dta"

*Transform population, taxes and employment variable
destring Pop_total, gen(pop_total)
gen p_unemployment = (Total_unempl*100)/pop_total
gen log_p_unemployment = log(1+p_unemployment)

gen p_employed = (Number_people_subject_inc_tax*100) / pop_total
gen log_p_employed = log(1+p_employed)

gen log_revenues = log( total_income_and_salary_tax)

*Generate east and west dummy
gen east = 0
replace east = 1 if land_num==11
replace east = 1 if land_num==12
replace east = 1 if land_num==13
replace east = 1 if land_num==14
replace east = 1 if land_num==15
replace east = 1 if land_num==16

*merge with 2017 dataset
drop _merge
merge 1:1 ags using "Files/Second_and_First_2017_prel.dta", force

*Create outcomes
*WITH AFD
egen p_radical_right_total_17 = rowtotal(SECOND_AfD_2017 SECOND_NPD_2017 SECOND_DIERECHTE_2017)
gen p_radical_right_17 = (p_radical_right_total_17*100)/Second_total_cast_2017

*WITHOUT AFD
egen p_radical_right_short_17 = rowtotal(SECOND_NPD_2017 SECOND_DIERECHTE_2017)
gen p_radical_right_17b = (p_radical_right_short_17*100)/Second_total_cast_2017

*calculate population density
destring Area, gen(area_num)
gen pop_density_17 = ( Total_eligible_voters_2017 / area_num)
gen log_pop_density_17 = log(1 + pop_density_17)


********************************************************************************
*
*		ANALYSIS
*
********************************************************************************


*FIGURE 2 Distribution of radical-right support and turnout (2013-2017)

kdensity p_radical, scheme(plottig) ///
	xtitle("Radical-right support (2013)") title("") name(hist_p_radical13, replace) 
	
kdensity p_radical_right_17, scheme(plottig) ///
	xtitle("Radical-right support (2017)") title("")  name(hist_p_radical17, replace) 


graph combine hist_p_radical13 hist_p_radical17, scheme(plottig)
*graph export "${output}histograms.png"
	
	
*FIGURE 3 Distance between \textit{Gemeinde}'s centroid and the closest concentration camp

hist distance_nearest_camp, scheme(plottig) ///
	xtitle("Distance to the nearest camp (in m)") title("") name(distance, replace) 
hist log_dist, scheme(plottig) ///
	xtitle("(Log) Distance to the nearest camp (in m)") title("") name(log_distance, replace) 

graph combine distance log_distance, scheme(plottig)
*graph export "${output}distance_camps.png"



*TABLE 1 The effect of distance to a camp on radical right-wing voting


*set global controls
global controls_past ///
	"c.weighted_pnsda_1930 c.weighted_p_jews_25  c.weighted_p_factory_33  i.east"

global controls_all ///
	"c.weighted_pnsda_1930 c.weighted_p_jews_25  c.weighted_p_factory_33  c.perc_male c.perc_cathol c.perc_foreign c.log_pop_density i.east"

global controls_all_17 ///
	"c.weighted_pnsda_1930 c.weighted_p_jews_25  c.weighted_p_factory_33  c.perc_male c.perc_cathol c.perc_foreign c.log_pop_density_17 i.east"
	
*Define labels to export
label variable log_dist "Distance to a concentration camp (log)"
label variable weighted_pnsda_1930 "\% votes NSDA (1930)"
label variable weighted_p_jews_25 "\% Jewish population (1925)"
label variable weighted_p_factory_33 "\% factory workers (1933)"
label variable perc_male "\% men (2013)"
label variable perc_cathol "\% Catholics (2013)"
label variable perc_foreign "\% Foreigners (2013)"
label variable log_pop_density "(Log) Population density (2013)"
label variable east "East lander"


eststo clear

****2013
*with AfD
eststo: reg p_radical log_dist    $controls_all      i.land_num 
eststo: reg p_radical c.log_dist##i.east  $controls_all  , vce(cluster land_num)
*WITHOUT AfD
eststo: reg p_radical_right log_dist    $controls_all      i.land_num   /*NOT SIGNIFICANT*/
eststo: reg p_radical_right c.log_dist##i.east  $controls_all i.land_num , vce(cluster land_num) /*SIGNIFICANT*/
****2017
*with AFD
eststo: reg p_radical_right_17 log_dist    $controls_all_17      i.land_num, vce(cluster land_num)   /*NOT SIGNIFICANT*/
eststo: reg p_radical_right_17 c.log_dist##i.east  $controls_all_17   i.land_num, vce(cluster land_num) /*SIGNIFICANT*/
*WITHOUT AFD	
eststo: reg p_radical_right_17b log_dist    $controls_all_17      i.land_num  /*NOT SIG*/
eststo: reg p_radical_right_17b c.log_dist##i.east  $controls_all_17  i.land_num  , vce(cluster land_num) /*NOT SIG*/


*esttab using "models_radicalvoting.tex", title("The effect of distance to a camp on radical right-wing voting") ///
*mtitles("M1" "M2" "M3" "M4" "M5") ///
*	 nogaps starlevels(+ 0.1 * 0.05 ** 0.01 ) ///
*	b(3) se(3) ar2 replace ///
*	 eqlabels(none) nonum  nogaps ///
*	interaction(" * ") compress label 


*FIGURE 5 The effect of being close to a concentration camp on radical-right vote

reg p_radical c.log_dist##i.east  $controls_all  , robust
margins east, at(log_dist=(4(1)12))
marginsplot, scheme(s1color) ytitle("% Radical right") title("") ///
	xtitle("(Log) distance to the nearest concentration camp") ///
	ytitle("Predicted radical-right support") ///
			title("2013") ///
	yline(0, lpattern(dash)) name(afd_2013, replace) ///
	plot( , label("West" "East"))

reg p_radical_right_17 c.log_dist##i.east    $controls_all_17   , robust
margins east, at(log_dist=(4(1)12))
marginsplot, scheme(s1color) ytitle("% Radical right") title("") ///
	xtitle("(Log) distance nearest concentration camp") ///
	ytitle("Predicted radical-right support") ///
		title("2017") ///
	 name(afd_2017, replace)	///
	plot( , label("West" "East"))


graph combine afd_2013 afd_2017, scheme(s1color)

	
*graph export "${output}figures_model_radicalvote.png", replace




********************************************************************************
*
*		APPENDIX
*
********************************************************************************



*FIGURE B1 The determinants of the location of concentration camps

*extreme left-wing
egen sum_radical_left = rsum(SECOND_MLPD SECOND_DIELINKE)
gen p_radical_left = (sum_radical_left*100)/Second_total_cast

label variable weighted_pnsda_1930 "% votes NSDA (1930)"
label variable weighted_pcommunist_1930 "% votes Communists (1930)"

twoway (scatter 	p_radical weighted_pnsda_1930) (lfit 	p_radical weighted_pnsda_1930), scheme(s1color) ///
	ytitle("% votes radical right (2013)") name(scatter_radical, replace) legend(off)

twoway (scatter 	p_radical_left weighted_pcommunist_1930) (lfit 	p_radical_left weighted_pcommunist_1930), scheme(s1color) ///
	ytitle("% votes radical left (2013)") name(scatter_left, replace) legend(off)

graph combine 	scatter_radical scatter_left,  graphregion(fcolor(white))
*graph export "${output}figures_persistency.png"
	

*FIGURE D1	The determinants of the location of concentration camps
gen log_population_33 =  log(1 + weighted_population_33)

reg log_dist c.weighted_pnsda_1930 c.weighted_p_jews_25  c.weighted_p_factory_33 weighted_p_land_25 ///
		log_population_33 i.east , vce(cluster land_num)	
coefplot , drop(_cons) xline(0)  scheme(s1color) ///
	coeflabels(weighted_pnsda_1930 = "% votes NSDA (1930)" weighted_p_jews_25 = "% Jewish population (1930)" ///
	weighted_p_factory_33 = "% factory workers (1933)" weighted_p_land_25 = "% land workers (1933)"   ///
	 log_population_33 = "(Log) Population density (1933)" 1.east= "East lander") ///
	xtitle("Coefficients with 99 and 95% CI") levels(99 95)
*graph export "${output}figures_model_endogenous.png", replace



log close
